//连文科
//2022年7月12日14:23:16
//自定义日志拦截器

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';

class MyInterceptors extends InterceptorsWrapper{

  @override
  void onRequest(RequestOptions options, RequestInterceptorHandler handler) async {
    // TODO: implement onRequest
    var sp = await SharedPreferences.getInstance();
    var userId = sp.getInt('userId');
    var token = sp.getString('token');
    if(userId == null) userId = 0;
    if(token == null) token = "";
    options.headers.addAll({'userId':userId,'token':token});
    super.onRequest(options, handler);
  }
}